var prefix="/online/";
$(function () {
	valid();
});
$.validator.setDefaults({
    submitHandler: function() {
    	update();
    }
});
function update(){
	var d=getFormJson("signupForm");
	if (!Array.isArray(d.roleIds)) {
		var roleIdArr=[];
		roleIdArr.push(d.roleIds);
		d.roleIds=roleIdArr;
	}
    var config={
			url : prefix+"/update",
			data:d,
	}
	EasyAjax.post_json(config,function(r){
		layer.msg(r.msg);
		if (r.code == 0){
			parent.reLoad();
			var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
			parent.layer.close(index);
		} 
	});
	
}
function valid(){
    var icon = "<i class='fa fa-times-circle'></i>";
    $("#signupForm").validate({
        rules:{
        	position: {
        		 required: true,
        	},
        	author: {
                required: true,
                maxlength: 5,
            },
        },
        messages: {
        	position: {
        		required:icon + "请输包名如:user",
        	},
        	author: {
        		required:icon + "作者不能为空",
        	},
        }
    });
}

